/**
 * 
 */
package neptune.web.client.model.topology;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * @author Roberto Bifulco [info@robertobifulco.it, robertobifulco.it]
 * 
 */
public class SerializableNetworkInterface implements IsSerializable {

	public static final String PHYSICAL_INTERFACE = "physical";
	public static final String NAT = "NAT";
	public static final String HIF = "HIF";
	public static final String BRIDGE = "bridge";
	public static final String UNDEFINED = "undefined";

	/**
	 * Il nome dato all'interfaccia dal sistema operativo
	 */
	private String interfaceName;
	/**
	 * Il nome del nodo che ospita questa interfaccia
	 */
	private String parentNode;
	/**
	 * Un codice testuale che indica come avviene il binding interfaccia
	 * virtuale-fisica
	 */
	private String bindingDescription;
	/**
	 * Gli indirizzi IP associati all'interfaccia
	 */
	private ArrayList<SerializableIPAddress> ipAddresses = new ArrayList<SerializableIPAddress>(
			0);
	/**
	 * Gli indirizzi MAC associati all'interfaccia
	 */
	private SerializableMACAddress macAddress;
	/**
	 * L'indirizzo di controllo definito su questa interfaccia, se presente
	 */
	private SerializableIPAddress controlAddress = null;
	/**
	 * Una stringa che identifica il tipo di interfaccia di rete
	 */
	private String type;

	/**
	 * @return the bindingDescription
	 */
	public String getBindingDescription() {
		return bindingDescription;
	}

	/**
	 * @return the controlAddress
	 */
	public SerializableIPAddress getControlAddress() {
		return controlAddress;
	}

	/**
	 * @return the interfaceName
	 */
	public String getInterfaceName() {
		return interfaceName;
	}

	/**
	 * @return the ipAddresses
	 */
	public ArrayList<SerializableIPAddress> getIpAddresses() {
		return ipAddresses;
	}

	/**
	 * @return the macAddress
	 */
	public SerializableMACAddress getMacAddress() {
		return macAddress;
	}

	public String getParentNode() {
		return parentNode;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	public void removeIpAddress(SerializableIPAddress addr) {
		for (int i = 0; i < ipAddresses.size(); i++) {
			if (ipAddresses.get(i).getAddress().equals(addr.getAddress())) {
				ipAddresses.remove(i);
				break;
			}
		}
	}

	/**
	 * @param bindingDescription
	 *            the bindingDescription to set
	 */
	public void setBindingDescription(String bindingDescription) {
		this.bindingDescription = bindingDescription;
	}

	/**
	 * @param controlAddress
	 *            the controlAddress to set
	 */
	public void setControlAddress(SerializableIPAddress controlAddress) {
		this.controlAddress = controlAddress;
	}

	/**
	 * @param interfaceName
	 *            the interfaceName to set
	 */
	public void setInterfaceName(String interfaceName) {
		this.interfaceName = interfaceName;
	}

	/**
	 * @param ipAddresses
	 *            the ipAddresses to set
	 */
	public void setIpAddresses(ArrayList<SerializableIPAddress> ipAddresses) {
		this.ipAddresses = ipAddresses;
	}

	/**
	 * @param macAddress
	 *            the macAddress to set
	 */
	public void setMacAddress(SerializableMACAddress macAddress) {
		this.macAddress = macAddress;
	}

	public void setParentNode(String parentNode) {
		this.parentNode = parentNode;
	}

	/**
	 * @param type
	 *            the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}
}
